/*
 * pml_shift_and.c
 *
 *  Created on: 2013年9月9日
 *      Author: lius
 */
#include <stdio.h>
#include "pml_shift_and.h"

int pml_shift_and_pre_proc(shift_and_st *st, unsigned char *pat, int pat_len)
{
	int i = 0;
	BITS tmp = BITS_LOW;

	for(;;)
	{
		st->mask[pat[i]] = st->mask[pat[i]] | tmp;
		if(++i == pat_len)
			break;
		tmp = tmp << 1;
	}
	st->match = tmp;
	return 0;
}

int pml_shift_and_match(shift_and_st *st, unsigned char *str, int str_len)
{
	BITS match_mask = BITS_INIT;
	int i = 0;
	for(;i < str_len; i++)
	{
		match_mask = ((match_mask << 1) | BITS_LOW) & st->mask[str[i]];
		if(match_mask & st->match)
		{
			printf("match %d\n", i);
		}
	}
	return 0;
}
